<!doctype html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<title>提交企业资质</title>
	<link rel="stylesheet" href="__MERCHANT_STATIC__/style/css/h-ui/css/H-ui.css">
	<link rel="stylesheet" href="__MERCHANT_STATIC__/style/css/styles.css">
	<link rel="stylesheet" href="__MERCHANT_STATIC__/style/css/public.css">
	<link rel="stylesheet" href="__MERCHANT_STATIC__/style/css/style.css">
	<link rel="stylesheet" type="text/css" href="__MERCHANT_STATIC__/style/js/uploadify/uploadify.css">
	<style type="text/css">
		.info select {
			border: 1px #ddd solid;
			background: #FFFFFF;
			width: 120px;
			height: 40px;
			border-radius: 6px;
		}

		.info {
			margin: 5px;
			text-align: center;
			top: -30px;
			width: 410px;
			margin-left: 70px;
		}

		#show {
			color: #3399FF;
		}

		.bottom {
			text-align: right;
			font-size: 12px;
			color: #CCCCCC;
			width: 1000px;
		}

		.amark {
			color: #FF0000;
		}

		#some_file_queue {
			background-color: #ffffff;
		}

		a:hover {
			cursor: pointer;
		}

		#frm {
			width: 1200px;
			border: none;
			margin: 0 auto;
			padding: 0 100px;
			box-sizing: border-box;
			overflow: hidden;
		}
		#frm .at{
			margin: 50px auto;
			cursor:pointer;
			height: 40px;
			line-height: 40px;
			width: 200px;
			text-align: center;
			border-radius: 3px;
			display: block;
		}
		.create_fileList {}

		.create_fileList .create_fileList_single input,
		select {
			height: 30px;
			margin: 0;
		}

		.create_fileList .create_fileList_single input[type="text"] {
			width: 300px;
		}
		.create_fileList .create_fileList_single input[type="file"] {
			/* position: absolute;
			left: 170px;
			top: 0; */
			display: block;
			margin:0 !important;
			margin-top: 10px !important;
			height: auto;
			
		}
		.create_fileList .create_fileList_single input[type="button"] {
			position: absolute;
			left: 190px;
			top: 110px;
		}

		.create_fileList .create_fileList_single select {
			width: 140px;
			margin-right: 15px;
		}

		.create_fileList_single {
			margin-bottom: 30px;
		}

		.create_fileList_single:after {
			content: "";
			display: block;
			clear: both;
		}

		.create_fileList_title {
			width: 160px;
			float: left;
			display: block;
			height: 30px;
			line-height: 30px;
			text-align: left;
			font-size: 16px;
			color: #333;
		}

		.create_fileList_singleContent {
			position: relative;
			float: right;
			width: calc(100% - 160px);
		}

		.create_fileList_singleContent .fanli,
		.fanli2,
		.fanli3,
		.fanli4,
		.fanli1 {
			position: absolute;
			color: #2196f3;
			font-size: 16px;
			top: 0;
			left: 180px;
		}

		.create_fileList_singleContent .radio-box {
			padding-left: 0;
			margin-right: 10px;
		}

		.create_fileList_prompt {
			margin-top: 10PX;
			font-size: 14px;
			color: #999999;
		}
	</style>
</head>

<body>
	{include file="common/business/header"}
	<!-- 入驻流程图 -->
	<ul class="common_stepLine">
		<li class="common_stepLine_single">
			<div class="common_stepLine_title common_stepLine_title--selected">
				<span class="common_stepLine_icon">
						1
				</span> 提交企业资质
			</div>
		</li>
		<li class="common_stepLine_single">
			<div class="common_stepLine_title">
				<span class="common_stepLine_icon">
						2
					</span> 填写店铺信息
			</div>
		</li>
		<li class="common_stepLine_single">
			<div class="common_stepLine_title">
				<span class="common_stepLine_icon">
						3
				</span> 入驻成功
			</div>
		</li>
	</ul>
	<!-- 入驻流程图 -->
	<form id="frm">
		{:token()}
		<ul class="create_fileList">
			<li class="create_fileList_single">
				<span class="create_fileList_title">
					<i class="update_red">*</i>营业执照扫描件
				</span>
				<div class="create_fileList_singleContent">
					<div>
						<input type="hidden" value="" id="license-img" name="enterprise_license_img">
						<img id="license" width="150px" height="150px" src="__MERCHANT_STATIC__/style/img/upload.png">
					</div>
					<div><a href="javascript:void(0);" class="fanli">范例 <img style="  height: 100%;width: 100%;min-width: 300px;min-height: 200px;" src="__MERCHANT_STATIC__/style/img/yingye.png" alt=""></a>
					</div>
					<p class="create_fileList_prompt">可上传最新的营业执照，复印件需加盖公章，支持png、jpg、gif等基本图片格式，图片小于2M</p>

				</div>
			</li>
			<li class="create_fileList_single">
				<span class="create_fileList_title">
					<i class="update_red">*</i>企业名称</span>
				<div class="create_fileList_singleContent">
					<input type="text" name="enterprise_name" id="enterprise_name" placeholder="与营业执照公司名一致，最多60个字" class="input-text radius size-M">

				</div>
			</li>
			<li class="create_fileList_single">
				<span class="create_fileList_title">
					<i class="update_red">*</i>注册资金</span>
				<div class="create_fileList_singleContent">
					<input id="enterprise_reg_amount" name="enterprise_reg_amount" type="text" class="input-text radius size-M"> 万元
					<span class="zijin span"></span>
				</div>
			</li>
			<li class="create_fileList_single">
				<span class="create_fileList_title">
					<i class="update_red">*</i>营业执照注册号
				</span>
				<div class="create_fileList_singleContent">
					<input name="enterprise_reg_number" id="enterprise_reg_number" type="text" placeholder="营业执照右上方注册号码" class="input-text radius size-M">
					<span class="yingye span"></span>
				</div>
			</li>
			<li class="create_fileList_single">
				<span class="create_fileList_title">
					<i class="update_red">*</i>营业执照有效期
				</span>
				<div class="create_fileList_singleContent">
					<input style="width:140px;" id="enterprise_license_reg_time" name="enterprise_license_reg_time" class="input-text radius size-M"
					    type="text" onClick="WdatePicker()" />
					<b style="color: #000;font-weight: normal;margin-left: 5px;">至</b>
					<input name="enterprise_license_end_time" id="enterprise_license_end_time" style="width:140px;" class="input-text radius size-M input-boxs" type="text"
					    onClick="WdatePicker()" />
					<input type="checkbox" name="enterprise_license_end_time_1" style="margin:0 0 0 8px" id="check-id">长期
					<span class="time span"></span>
				</div>
			</li>
			<li class="create_fileList_single">
				<span class="create_fileList_title">
					<i class="update_red">*</i>营业执照所在地
				</span>
				<div class="create_fileList_singleContent">

					<select name="province" id="province"></select>
					<select name="city" id="city"></select>
					<!-- <input type="hidden" name="enterprise_province" value=""> 
					<input type="hidden" name="enterprise_city" value="">  -->
					
				</div>
			</li>
			<li class="create_fileList_single">
				<span class="create_fileList_title">
					<i class="update_red">*</i>法人姓名
				</span>
				<div class="create_fileList_singleContent">
					<input type="text" id="enterprise_legal_person" name="enterprise_legal_person" placeholder="请输入法人姓名" class="input-text radius size-M">
					<span class="name span"></span>
				</div>
			</li>
			<li class="create_fileList_single">
				<span class="create_fileList_title">
					<i class="update_red">*</i>联系人姓名
				</span>
				<div class="create_fileList_singleContent">
					<input name="enterprise_contacts_person" id="enterprise_contacts_person" type="text" placeholder="请输入联系人姓名" class="input-text radius size-M">
					<span class="lianxi span"></span>
				</div>
			</li>
			<li class="create_fileList_single">
				<span class="create_fileList_title">
					<i class="update_red">*</i>联系人手机
				</span>
				<div class="create_fileList_singleContent">
					<input name="enterprise_contacts_tel" id="enterprise_contacts_tel" type="text" placeholder="请输入联系人手机" class="input-text radius size-M">
					<span class="phone span"></span>
				</div>
			</li>
			<li class="create_fileList_single">
				<span class="create_fileList_title">
					<i class="update_red">*</i>是否多证合一
				</span>
				<div class="create_fileList_singleContent">
					<div class="radio-box">
						<input type="radio" checked="checked" id="radio-1" value="1" name="enterprise_is_certificates">
						<label for="radio-1">是</label>
					</div>
					<div class="radio-box">
						<input type="radio" value="2" id="radio-2" name="enterprise_is_certificates">
						<label for="radio-2">否</label>
					</div>
				</div>
			</li>
			<div class="box-show" style="display: none;">

				<li class="create_fileList_single">
					<span class="create_fileList_title">
					<i class="update_red">*</i>组织机构代码有效期
				</span>
					<div class="create_fileList_singleContent">
						<input style="width:140px;" name="enterprise_organization_code_reg_time" id="enterprise_organization_code_reg_time" class="input-text radius size-M"
						    type="text" onClick="WdatePicker()" />
						<b>至</b>
						<input name="enterprise_organization_code_end_time" id="enterprise_organization_code_end_time" style="width:140px;" class="input-text radius size-M" type="text" onClick="WdatePicker()" />
					</div>
				</li>
				<li class="create_fileList_single">
					<span class="create_fileList_title">
					<i class="update_red">*</i>组织机构代码扫描件
				</span>
					<div class="create_fileList_singleContent">
						<div >
							<input type="hidden" value="" id="organization-img" name="enterprise_organization_code_img">
							<img id="organization" width="150px" height="150px" src="__MERCHANT_STATIC__/style/img/upload.png" />
						</div>
						<div>
							<a href="javascript:void(0);" class="fanli1">范例 <img style="max-width:179px;height:120px" src="__MERCHANT_STATIC__/style/img/zuzhi.png" alt=""></a>
						</div>
						<p class="create_fileList_prompt">可上传最新的组织机构代码，复印件需加盖公章，支持png、jpg、gif等基本图片格式，图片小于2M</p>
						<span class="jigou span"></span>
					</div>
				</li>
				<li class="create_fileList_single">
					<span class="create_fileList_title">
					<i class="update_red">*</i>税务登记证扫描件
				</span>
					<div class="create_fileList_singleContent">
						<div >
							<input type="hidden" value="" id="tax-certificate-img" name="enterprise_registration_certificate_img">
							<img id="tax-certificate" width="150px" height="150px" src="__MERCHANT_STATIC__/style/img/upload.png" />
						</div>
						<div style="margin-left: 450px;">
							<a href="javascript:void(0);" class="fanli2">范例 <img style="max-width:170px;height:119px"  src="__MERCHANT_STATIC__/style/img/shuiwu.png" alt=""></a>
						</div>
						<p class="create_fileList_prompt">可上传最新的税务登记，复印件需加盖公章，支持png、jpg、gif等基本图片格式，图片小于2M</p>
						<span class="shuiwu span"></span>
					</div>
				</li>
			</div>

			<li class="create_fileList_single">
				<span class="create_fileList_title">
					<i class="update_red">*</i>法人身份证正面
				</span>
				<div class="create_fileList_singleContent">
					<div>
						<input type="hidden" value="" id="card-front-img" name="enterprise_idc_up_img">
						<img id="card-front" width="150px" height="150px" src="__MERCHANT_STATIC__/style/img/upload.png" />	
					</div>
					<div style="margin-left: 450px;">
						<a href="javascript:void(0);" class="fanli3">范例 <img style="  height: 100%;width: 100%;min-width: 200px;min-height: 140px;" src="__MERCHANT_STATIC__/style/img/id-zheng.png" alt=""></a>
					</div>
					<p class="create_fileList_prompt">扫描件，复印件需加盖公章，支持png、jpg、gif等基本图片格式，图片小于2M</p>

				</div>
			</li>
			<li class="create_fileList_single">
				<span class="create_fileList_title">
					<i class="update_red">*</i>法人身份证反面
				</span>
				<div class="create_fileList_singleContent">
					<div>
						<input type="hidden" value="" id="card-back-img" name="enterprise_idc_down_img">
						<img id="card-back" width="150px" height="150px" src="__MERCHANT_STATIC__/style/img/upload.png" />						
					</div>
					<div style="margin-left: 450px;">
						<a href="javascript:void(0);" class="fanli4">范例 <img style="  height: 100%;width: 100%;min-width: 200px;min-height: 140px;"  src="__MERCHANT_STATIC__/style/img/id-fan.png" alt=""></a>
					</div>
					<p class="create_fileList_prompt">扫描件，复印件需加盖公章，支持png、jpg、gif等基本图片格式，图片小于2M</p>
					<span class="id-fan span"></span>
				</div>
			</li>
		</ul>
		<a href="javascript:void(0);" class="at" onclick="formAction();">下一步</a>
	</form>
	<!-- 插入底部模块 -->
	{include file="enterprise/footer" /}

	<script type="text/javascript" src="__MERCHANT_STATIC__/hui/lib/jquery/1.9.1/jquery.min.js"></script>
	<script src="__MERCHANT_STATIC__/style/js/jquery.js"></script>
	<script src="__MERCHANT_STATIC__/style/js/moment.js"></script>
	<!-- <script src="__MERCHANT_STATIC__/style/js/uploadify/jquery.uploadify.min.js" type="text/javascript"></script> -->
	<script type="text/javascript" src="__WWW_STATIC__/www/index/layer/layer.js">
	</script>
	<script language="javascript" src="__MERCHANT_STATIC__/style/js/PCASClass.js"></script>
	<script language="javascript" type="text/javascript" src="__MERCHANT_STATIC__/My97DatePicker/WdatePicker.js"></script>
	<script src="__WWW_STATIC__/lib/plupload/plupload.full.min.js"></script>
<script type="text/javascript">
	$(".span:contains('首页')").css("color","#4990E2").siblings().css("display","block")
	new PCAS("province", "city", "请选择省份", "");
	$('#radio-1').on('click', function () {
		$('.box-show').hide();
	})
	$('#radio-2').on('click', function () {
		$('.box-show').show();
	})
	$('#check-id').on('click', function () {
		if ($('#check-id').prop('checked')) {
			$('#check-id').prop('checked', true);
			$('#enterprise_license_end_time').attr('disabled', 'disabled');
			$('#enterprise_license_end_time').val('');
		} else {
			$('#check-id').prop('checked', false);
			$('#enterprise_license_end_time').removeAttr('disabled');
		}
	});
	$('#enterprise_license_end_time').on('blur', function () {
		if ($(this).val() != '') {
			$('#check-id').attr('disabled', 'disabled');
		} else {
			$('#check-id').removeAttr('disabled');
		}
	})

	function formAction() {
		if ($("#license-img").val() == '') {
			layer.msg("请上传营业执照扫描件");
			return;
		}
		if ($("#enterprise_name").val() == '') {
			layer.msg("企业名称名称不能为空");
			$("#enterprise_name").focus();
			return;
		}
		if ($("#enterprise_reg_amount").val() == '') {
			layer.msg("注册资金不能为空");
			$("#enterprise_reg_amount").focus();
			return;
		}
		if ($("#enterprise_reg_number").val() == '') {
			layer.msg("营业执照注册号不能为空");
			$("#enterprise_reg_number").focus();
			return;
		}
		if ($("#enterprise_license_reg_time").val() == '') {
			layer.msg("营业执照有效期不能为空");
			$("#enterprise_license_reg_time").focus();
			return;
		}
		if(!$('#check-id').prop('checked')) {
			if ($("#enterprise_license_end_time").val() == '') {
				layer.msg("营业执照有效期不能为空");
				$("#enterprise_license_end_time").focus();
				return;
			}
		}
		if ($("#province").val() == '') {
			layer.msg("营业执照所在地不能为空");
			$("#province").focus();
			return;
		}
		if ($("#city").val() == '') {
			layer.msg("营业执照所在地不能为空");
			$("#city").focus();
			return;
		}

		if ($("#enterprise_legal_person").val() == '') {
			layer.msg("法人姓名不能为空");
			$("#enterprise_legal_person").focus();
			return;
		}

		if ($("#enterprise_contacts_person").val() == '') {
			layer.msg("联系人姓名不能为空");
			$("#enterprise_contacts_person").focus();
			return;
		}

		if ($("#enterprise_contacts_tel").val() == '') {
			layer.msg("联系人手机不能为空");
			$("#enterprise_contacts_tel").focus();
			return;
		}
		
		if($("input[name='enterprise_is_certificates']:checked").val() == 2) {
			if ($("#enterprise_organization_code_reg_time").val() == '') {
				layer.msg("组织机构代码有效期不能为空");
				$("#enterprise_organization_code_reg_time").focus();
				return;
			}
			if ($("#enterprise_organization_code_end_time").val() == '') {
				layer.msg("组织机构代码有效期不能为空");
				$("#enterprise_organization_code_end_time").focus();
				return;
			}
			if ($("#organization-img").val() == '') {
				layer.msg("请上传组织机构代码扫描件");
				return;
			}
			if ($("#tax-certificate-img").val() == '') {
				layer.msg("请上传税务登记证扫描件");
				return;
			}
		}
		
		if ($("#card-front-img").val() == '') {
			layer.msg("请上传法人身份证正面");
			return;
		}
		
		if ($("#card-back-img").val() == '') {
			layer.msg("请上传法人身份证背面");
			return;
		}

		$.ajax({
			type: "POST",
			url: "<?php echo url('enterprise/insert', '', false); ?>",
			dataType: 'json',
			cache: false,
			data: $('#frm').serialize(),
			success: function (data) {
				if (data.status == 1) {
					location.href = "{:url('store/create')}";
				} else {
					layer.msg(data.msg);
				}

			},
			error: function (xhr, status, error) {

			}
		});
	}
		
	//实例化一个plupload上传对象（营业执照）
	var uploader_license = new plupload.Uploader({ 
	browse_button : "license",
	url : "{:url('enterprise/uploadImg')}",
	filters : {
		mime_types : [ //只允许上传图片
			{ title : 'Image files', extensions : 'jpg,jpeg,png' }
		],
		max_file_size : '2048kb', //最大只能上传2Mb的文件
		//prevent_duplicates : true //不允许选取重复文件
	},
	multipart_params : {  //附加参数
		type:1,
	},
	multi_selection : false,
	unique_names : true  //上传的文件生成唯一的name值
	});

	//初始化
	uploader_license.init(); 

	uploader_license.bind('FilesAdded', function(uploader, files){
		uploader.start(); //开始上传
	});

	//绑定单个文件上传完成后事件
	uploader_license.bind('FileUploaded', function(uploader, file, res){
		// 获取返回的img src值
		var r = JSON.parse(res.response);
		$('#license').attr('src', r.data.imgRoot + r.data.imgName);
		$('#license-img').val(r.data.imgName);
	});

	//绑定所有文件上传完成后事件
	uploader_license.bind('UploadComplete', function(uploader, files){
		uploader.files.length = 0;  //清空上传队列
	});
	
	//实例化一个plupload上传对象（组织机构）
	var uploader_o = new plupload.Uploader({ 
	browse_button : "organization",
	url : "{:url('enterprise/uploadImg')}",
	filters : {
		mime_types : [ //只允许上传图片
			{ title : 'Image files', extensions : 'jpg,jpeg,png' }
		],
		max_file_size : '2048kb', //最大只能上传2Mb的文件
		//prevent_duplicates : true //不允许选取重复文件
	},
	multipart_params : {  //附加参数
		type:2,
	},
	multi_selection : false,
	unique_names : true  //上传的文件生成唯一的name值
	});

	//初始化
	uploader_o.init(); 

	uploader_o.bind('FilesAdded', function(uploader, files){
		uploader.start(); //开始上传
	});

	//绑定单个文件上传完成后事件
	uploader_o.bind('FileUploaded', function(uploader, file, res){
		// 获取返回的img src值
		var r = JSON.parse(res.response);
		$('#organization').attr('src', r.data.imgRoot + r.data.imgName);
		$('#organization-img').val(r.data.imgName);
	});

	//绑定所有文件上传完成后事件
	uploader_o.bind('UploadComplete', function(uploader, files){
		uploader.files.length = 0;  //清空上传队列
	});
	
	//实例化一个plupload上传对象（税务登记）
	var uploader_t = new plupload.Uploader({ 
	browse_button : "tax-certificate",
	url : "{:url('enterprise/uploadImg')}",
	filters : {
		mime_types : [ //只允许上传图片
			{ title : 'Image files', extensions : 'jpg,jpeg,png' }
		],
		max_file_size : '2048kb', //最大只能上传2Mb的文件
		//prevent_duplicates : true //不允许选取重复文件
	},
	multipart_params : {  //附加参数
		type:3,
	},
	multi_selection : false,
	unique_names : true  //上传的文件生成唯一的name值
	});

	//初始化
	uploader_t.init(); 

	uploader_t.bind('FilesAdded', function(uploader, files){
		uploader.start(); //开始上传
	});

	//绑定单个文件上传完成后事件
	uploader_t.bind('FileUploaded', function(uploader, file, res){
		// 获取返回的img src值
		var r = JSON.parse(res.response);
		$('#tax-certificate').attr('src', r.data.imgRoot + r.data.imgName);
		$('#tax-certificate-img').val(r.data.imgName);
	});

	//绑定所有文件上传完成后事件
	uploader_t.bind('UploadComplete', function(uploader, files){
		uploader.files.length = 0;  //清空上传队列
	});
	
	//实例化一个plupload上传对象（身份证正面）
	var uploader_idcf = new plupload.Uploader({ 
	browse_button : "card-front",
	url : "{:url('enterprise/uploadImg')}",
	filters : {
		mime_types : [ //只允许上传图片
			{ title : 'Image files', extensions : 'jpg,jpeg,png' }
		],
		max_file_size : '2048kb', //最大只能上传2Mb的文件
		//prevent_duplicates : true //不允许选取重复文件
	},
	multipart_params : {  //附加参数
		type:4,
	},
	multi_selection : false,
	unique_names : true  //上传的文件生成唯一的name值
	});

	//初始化
	uploader_idcf.init(); 

	uploader_idcf.bind('FilesAdded', function(uploader, files){
		uploader.start(); //开始上传
	});

	//绑定单个文件上传完成后事件
	uploader_idcf.bind('FileUploaded', function(uploader, file, res){
		// 获取返回的img src值
		var r = JSON.parse(res.response);
		$('#card-front').attr('src', r.data.imgRoot + r.data.imgName);
		$('#card-front-img').val(r.data.imgName);
	});

	//绑定所有文件上传完成后事件
	uploader_idcf.bind('UploadComplete', function(uploader, files){
		uploader.files.length = 0;  //清空上传队列
	});
	
	//实例化一个plupload上传对象（身份证背面）
	var uploader_idcb = new plupload.Uploader({ 
	browse_button : "card-back",
	url : "{:url('enterprise/uploadImg')}",
	filters : {
		mime_types : [ //只允许上传图片
			{ title : 'Image files', extensions : 'jpg,jpeg,png' }
		],
		max_file_size : '2048kb', //最大只能上传2Mb的文件
		//prevent_duplicates : true //不允许选取重复文件
	},
	multipart_params : {  //附加参数
		type:5,
	},
	multi_selection : false,
	unique_names : true  //上传的文件生成唯一的name值
	});

	//初始化
	uploader_idcb.init(); 

	uploader_idcb.bind('FilesAdded', function(uploader, files){
		uploader.start(); //开始上传
	});

	//绑定单个文件上传完成后事件
	uploader_idcb.bind('FileUploaded', function(uploader, file, res){
		// 获取返回的img src值
		var r = JSON.parse(res.response);
		$('#card-back').attr('src', r.data.imgRoot + r.data.imgName);
		$('#card-back-img').val(r.data.imgName);
	});

	//绑定所有文件上传完成后事件
	uploader_idcb.bind('UploadComplete', function(uploader, files){
		uploader.files.length = 0;  //清空上传队列
	});	
</script>
</body>
</html>